<?php
namespace app\admin\helper;

class Form
{
	private $fields = null;//array
	private $data = null;//array
	private $fieldtmp = [
		'title'=>'title.html',
	];
	private $typetmp= [
		'text'=>'text.html',
		'datetime'=>'datetime.html',
	];
	private $tmpdir = '';//
    /**
     * [gettype 获取字段类型]
     * @param  [type] $fieldname [description]
     * @return [type]            [description]
     */
    public function gettype($fieldname)
    {
    	return $this->fetch();
    }
    /**
     * [gettmp 获取模板]
     * @param  [type] $fieldname [description]
     * @return [type]            [description]
     */
    public function gettmp($fieldname)
    {
    	if(isset($this->fieldtmp[$fieldname]))
    	{
    		return $this->fieldtmp[$fieldname];
    	}
    	$type = $this->fields[$fieldname];
    	$this->fieldtmp[$fieldname] = $this->typetmp[$type];
    	return $this->fieldtmp[$fieldname];
    }
    /**
     * [getfields 获取表单字段数组]
     * @return [type] [description]
     */
    public function getfields()
    {

    }
    /**
     * [settmp 设置字段对应模板]
     * @param  [type] $fieldname [description]
     * @param  [type] $tmp       [description]
     * @return [type]            [description]
     */
    public function settmp($fieldname, $tmp)
    {
    	$this->fieldtmp[$fieldname] = $tmp;
    }
    public function getvalue($fieldname)
    {
    	if(isset($this->data[$fieldname]))
    	{
    		return $this->data[$fieldname];
    	}
    	return null;
    }
}
